#ifndef _GAMEGOODS_MANAGER_H_
#define _GAMEGOODS_MANAGER_H_

#include "Common.h"
#include "String.h"
#include "Resource.h"
#include "ItemManager.h"

// 商品标志位
enum GoodsFlagDef
{
	GoodsFlag_Gold = 0x8, // 元宝购买
	GoodsFlag_Lottery = 0x10, // 兑换券购买
	GoodsFlag_ToGateway = 0x20, // 去网关
	GoodsFlag_Coins = 0x40, // 铜钱购买
	GoodsFlag_Score = 0x80, // 积分购买
};
// 标签类型
enum AssortType
{
	en_AT_Common = 1, // 一般商品
	en_AT_Medal= 2,	// 勋章
	en_AT_Prop = 3, // 道具
	en_AT_Character = 4, // 角色类
	en_AT_RealObject = 5, // 实物兑换 
	en_AT_Honor = 6, // 勋章
};
// 商城类型
enum ShopType
{
	en_ShopT_GoldShop = 1, // 元宝商城
	en_ShopT_LotteryShop = 2, // 兑换券商城
	en_ShopT_Largess = 3,	// 系统赠送
};


#define WGS_GOODSMGR_INNER_MUTEX_NAME goodsMgr_inner_mutex
#define WGS_GOODSMGR_INNER_MUTEX mutable boost::mutex WGS_GOODSMGR_INNER_MUTEX_NAME;
#define WGS_GOODSMGR_INNER_LOCK		boost::lock_guard<boost::mutex> wgsGoodsMgrInnerMutexLock(WGS_GOODSMGR_INNER_MUTEX_NAME);
//------------------------------------------------------------
class GameGoodsManager : public Singleton<GameGoodsManager>
{
public:
	GameGoodsManager(void);
	~GameGoodsManager(void);
	
	void load(void);
	void Reload();
	/**获取商品属性(非安全)
	*参数:
	*	model_id:物品模式号	buy_type:兑换货币类型,默认为元宝
	*/
	const GameGoods * GetGameGoods(const uint32 & model_id, const GoodsFlagDef & buy_type = GoodsFlag_Gold);
	/**
	 * 获取指定ID的商品(非安全)
	 * 参数：
	 * 	@goodsId 商品ID
	 * 返回：商品
	 */
	const GameGoods * GetGameGoodsById(const uint32 & goodsId);
	/**
	 * 获取指定ID的商品(安全)
	 */
	bool GetGameGoodsById(const uint32 goodsId, GameGoods &pGoods);
	
	/**获取商品价值
	*参数:
	*	model_id:物品模式号	buy_type:兑换货币类型
	*/
	uint32 GetGoodsPrice(const uint32 & model_id, const GoodsFlagDef & buy_type = GoodsFlag_Gold);
	/**
	 * 获取指定类型某页的商品列表
	 * 参数：
	 * 	@pGoodsList 存放获取的商品
	 *  @shopType 商城类型
	 *  @supId 运营商ID
	 *  @type 分类类型
	 *  @page 请求页数
	 *  @number 每页数量
	 * 返回：总页数
	 */
	uint8 GetGoodsList(std::list<GameGoods*> *pGoodsList, const uint8 shopType, const uint32 supId, const uint8 labelType, const uint8 page, const uint8 number);
	
	/*
	
	
	*/
	bool	BuyGoods(const uint32 &serial, const uint32 &goodsId, const uint32 &number);

protected:
	WGS_GOODSMGR_INNER_MUTEX
	std::list<GameGoods>  m_goodsList;
};

#define   sGoodsMgr   GameGoodsManager::getSingleton()
/* 
//------------------------------------------------------------
#define DISCOUNT_UNLIMITED	999999	// 不限购
enum DiscountStatus
{
	DiscountStatus_None = 0,		// 未出售
	DiscountStatus_Process= 2,		// 进行中
	DiscountStatus_End = 3,			// 结束
};

struct DiscountGoods
{
	uint32 id;
	uint32 src_id;
	uint32 model_id;
	uint32 org_price;
	uint32 price;
	uint32 curr_num;
	uint32 begin_time;
	uint32 end_time;
	uint8 status;
	DiscountGoods():id(0),src_id(0),model_id(0),org_price(0),price(0),
					curr_num(0),begin_time(0),end_time(0),status(0){}
};

#define WGS_DISCGOODSMGR_INNER_MUTEX_NAME descgoodsMgr_inner_mutex
#define WGS_DISCGOODSMGR_INNER_MUTEX mutable boost::mutex WGS_DISCGOODSMGR_INNER_MUTEX_NAME;
#define WGS_DISCGOODSMGR_INNER_LOCK		boost::lock_guard<boost::mutex> wgsdescGoodsMgrInnerMutexLock(WGS_DISCGOODSMGR_INNER_MUTEX_NAME);
class WorldPacket;
//------------------------------------------------------------
class DiscountManager : public Singleton<DiscountManager>
{
public:
WGS_DISCGOODSMGR_INNER_MUTEX
	DiscountManager(void);
	
	void loadXml();
	void reloadXml();
	
	void OnUpdate(void);
	bool BuyGoods(const uint32 & model_id, const uint32 & num = 1);
	void BroadcastList(void);
protected:
	
	bool CreateDiscountGoodsPacket(WorldPacket * packet, std::list<DiscountGoods> & lstDiscount);
	
protected:
	std::list<DiscountGoods> m_lstDiscount;
	uint32 m_lasttime;
};

#define   sDiscountMgr   DiscountManager::getSingleton()

 */
#endif
